<template>
  <div>
    <!--添加雷达-->
    <div class="radar" @click="addRadar">添加雷达</div>
    <!--显示雷达范围-->
    <div class="controlBox" v-show="$store.state.radar.radarUI">
      <div>radarId: {{$store.state.radar.radarId}}</div>
      <div class="radarArea" @click="showRadarArea">{{message}}</div>
      <!--控制雷达旋转-->
      <div class="rotation">
        <div class="left" @click="turnLeft"></div>
        <div class="right" @click="turnRight"></div>
      </div>
    </div> 
  </div>
</template>

<script>
  import addRadar from 'assets/js/CesiumFun/radarOperate/addRadar'      // 添加雷达
  import radarClick from 'assets/js/CesiumFun/radarOperate/radarClick'  // 雷达点击
  import { radarLeft, radarRight } from 'assets/js/CesiumFun/radarOperate/radarRotation'

  export default {
    props: {
      viewer: undefined,
      scene: undefined
    },
    name: '',
    data() {
      return {
        radarId: 1,     // 雷达Id
        radarPosition: {// 雷达位置
          lon: 120.43153, lat: 36.31404, height: 10
        },
        message: "隐藏雷达范围",
        showRadar: true,       // 更改message,
      }
    },
    components: {

    },
    methods: {
      // 添加雷达
      addRadar() {
        addRadar(this.viewer,this.scene, this.radarPosition, this.radarId);
        this.radarPosition.lon += 0.00005;
        this.radarId += 1;
        radarClick(this.viewer)// 给每个雷达添加点击方法（左键移动）
      },
      // 雷达左旋转
      turnLeft() {
        radarLeft();
      },
      // 雷达右旋转
      turnRight() {
        radarRight();
      },
      // 是否显示雷达范围
      showRadarArea() {
        // 查找雷达区域
        var collection = this.$store.state.radar.radarAreaCollection;
        var radar = this.$store.getters.searchRadarArea;
        if(this.showRadar){
          radar.show = false;
          this.message="显示雷达区域";
          this.showRadar = false;
        }
        else {
          radar.show = true;
          this.message="隐藏雷达区域";
          this.showRadar = true;
        }
      }

    }
  }
</script>

<style scpoed>
@import '~assets/css/Cesium/radar/index.css';
</style>